<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main2"/>
    <title>商机列表</title>
</head>

<body>
<div class="main-body">
    <div class="page-wrapper">
        <!-- Page-header start -->
        <div class="page-header">
            <div class="page-header-title">
                <h4>商机列表</h4>
            </div>

            <div class="page-header-breadcrumb">
                <ul class="breadcrumb-title">
                    <li class="breadcrumb-item">
                        <a href="/salesDashboard/index">
                            <i class="icofont icofont-home"></i>
                        </a>
                    </li>
                    <li class="breadcrumb-item"><a href="#!">商机列表</a>
                    </li>
                </ul>
            </div>
        </div>
        <!-- Page-header end -->
        <!-- Page-body start -->
        <div class="page-body">
            <!-- Hover table card start -->
            <div class="card">
                <div class="card-header">
                    <h5>商机列表</h5>

                    <div class="card-header-right">
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>

                <div class="card-block dt-responsive">

                    <div class="table-responsive">
                        <div id="dom-jqry_wrapper" class="dataTables_wrapper dt-bootstrap4">

                            <g:form method="POST" action="searchOpportunity">
                                <div class="row m-0">
                                    <div class="col-md-8 p-l-0">
                                        <div id="order-table_filter" class="dataTables_filter text-left">
                                            <label>搜索<input type="text" class="form-control" placeholder="商机号"
                                                            name="serialNumber"
                                                            id="serialNumber"
                                                            value="${params?.serialNumber}">
                                            </label>
                                        </div>
                                    </div>
                                    <div class="col-md-4 p-r-0 dt-buttons text-right">
                                        <button class="btn btn-success btn-mini" type="submit"><i
                                                class="icofont icofont-search"></i>搜索
                                        </button>
                                        <button class="btn btn-warning btn-mini" type="button"
                                                id="resetBtn"><i
                                                class="icofont icofont-close"></i>重置</button>
                                      
                                    </div>
                                </div>
                            </g:form>
                           <!--  <g:form method="POST" action="exportOpportunity">
                                <div class="row m-0">
                                    <input type="hidden" class="form-control" placeholder="商机号" name="serialNumber" id="exportSerialNumber" value="${params?.serialNumber}">
                                    <input type="hidden" class="form-control" placeholder="文件类型" name="f" value="excel">
                                    <input type="hidden" class="form-control" placeholder="后缀" name="extension" value="xls">
                                    <div class="col-md-12 p-r-0 dt-buttons text-right">
                                    <button class="btn btn-success btn-mini" type="submit"><i class="icofont icofont-search"></i>导出
                                    </button>
                                </div>
                                </div>
                            </g:form> -->
                            <table class="table table-striped  table-bordered table-hover">
                                <thead>
                                <tr>
                                    <g:sortableColumn property="serialNumber" title="商机号"></g:sortableColumn>
                                    <g:sortableColumn property="account" title="客户名称"></g:sortableColumn>
                                    <g:sortableColumn property="amount" title="金额"></g:sortableColumn>
                                    <g:sortableColumn property="probability" title="几率"></g:sortableColumn>
                                    <g:sortableColumn property="status" title="状态"></g:sortableColumn>
                                    <g:sortableColumn property="stage" title="阶段"></g:sortableColumn>
                                    <g:sortableColumn property="product" title="产品"></g:sortableColumn>
                                    <g:sortableColumn property="startTime" title="商机发现时间"></g:sortableColumn>
                                    <g:sortableColumn property="endTime" title="客户预计采购时间"></g:sortableColumn>
                                </tr>
                                </thead>
                                <tbody>
                                <g:each in="${opportunityList}">
                                    <tr>
                                        <td>
                                            <g:link action="show" id="${it?.id}">${it?.serialNumber}</g:link>
                                        </td>
                                        <td>${it?.account}</td>
                                        <td>${it?.amount}</td>
                                        <td>${it?.probability}</td>
                                        <td>${it?.status?.name}</td>
                                        <td>${it?.stage?.name}</td>
                                        <td>${it?.product?.name}</td>
                                        <td><g:formatDate date="${it?.startTime}"
                                                          format="yyyy-MM-dd"></g:formatDate></td>
                                        <td><g:formatDate date="${it?.endTime}"
                                                          format="yyyy-MM-dd"></g:formatDate></td>
                                    </tr>
                                </g:each>
                                </tbody>
                            </table>

                            <div class="dataTables_paginate">
                                 <div class="pagination">
                                    <g:paginate total="${opportunityCount ?: 0}" params="${params}"/>

                                 </div>
                            </div>

                        </div>

                    </div>

                </div>
            </div>
            <!-- Hover table card end -->
        </div>

        <!-- Page-body end -->
    </div>
</div>

<g:javascript>
    $(function () {
        $("#serialNumber").keyup(function() {
            $("#exportSerialNumber").val($(this).val());
        })
        $("#resetBtn").click(function () {
            $("#serialNumber").val("");
        })
    });

</g:javascript>
</body>
</html>
